﻿using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web;

namespace ControleRepresentante.UnitTests.Mocks
{
    public class MockHttpRequest : HttpRequestBase
    {
        private readonly Dictionary<string, string> m_Vales;
        private readonly NameValueCollection m_Query;

        public MockHttpRequest(Dictionary<string, string> vales, Dictionary<string, string> query)
        {
            m_Vales = vales;
            m_Query = new NameValueCollection();
            foreach (KeyValuePair<string, string> keyValuePair in query)
            {
                m_Query.Add(keyValuePair.Key, keyValuePair.Value);
            }
        }

        public MockHttpRequest()
        {
            m_Vales = new Dictionary<string, string>();
            m_Query = new NameValueCollection();
        }

        public override string this[string key]
        {
            get
            {
                string value;
                return m_Vales.TryGetValue(key, out value) ? value : null;
            }
        }
        public override NameValueCollection QueryString { get { return m_Query; } }
    }
}